package com.hilton.tigershark.downloads;

import android.net.Uri;
import android.provider.BaseColumns;

public class Downloads implements BaseColumns {
    public static final Uri CONTENT_URI = Uri.parse("content://" + DownloadProvider.AUTHORITY + "/" + DownloadProvider.TABLE_NAME);
    
    public static final String URL = "url";
    public static final String 	PATH = "_data";
    public static final String FILENAME = "filename";
    public static final String MIME_TYPE = "mime_type";
    public static final String CURRENT_BYTES = "current_bytes";
    public static final String TOTAL_BYTES = "total_bytes";
    public static final String CREATED = "created";
    public static final String STATUS = "status";
    
    public static final String[] PROJECTION = new String[] {
	_ID,
	URL,
	PATH,
	FILENAME,
	MIME_TYPE,
	CURRENT_BYTES,
	TOTAL_BYTES,
	CREATED,
	STATUS,
    };
    public static final int ID_INDEX = 0;
    public static final int URL_INDEX = 1;
    public static final int PATH_INDEX = 2;
    public static final int FILENAME_INDEX = 3;
    public static final int MIME_TYPE_INDEX = 4;
    public static final int CURRENT_BYTES_INDEX = 5;
    public static final int TOTAL_BYTES_INDEX = 6;
    public static final int CREATED_INDEX = 7;
    public static final int STATUS_INDEX = 8;
    
    public static class DownloadStatus {
	public static final int STATUS_DOWNLOADING = 0;
	public static final int STATUS_FAILED = 1;
	public static final int STATUS_COMPLETED = 2;
	
	private static final String[] STATUS_LABEL = {
	    "Downloading",
	    "Failed",
	    "Completed",
	};
	
	public static String readableStatusLabel(int status) {
	    if (status < STATUS_DOWNLOADING || status > STATUS_COMPLETED) {
		throw new IllegalArgumentException("Bad status: " + status);
	    }
	    return STATUS_LABEL[status];
	}
    }
}